<template>
  <div v-html="htmlContent"></div>
</template>

<script setup lang="ts">
import { computed, onMounted, ref, toRefs } from 'vue'

const props = withDefaults(defineProps<{ vueFileAbsolutePath?: string }>(), {
  vueFileAbsolutePath: '',
})

const vueCompInfoMarkdownMap = ref<Record<string, string>>()
const { vueFileAbsolutePath } = toRefs(props)
const htmlContent = computed(() => {
  const vueCompInfoMarkdown = vueCompInfoMarkdownMap.value
  const filePath = vueFileAbsolutePath.value
  if (vueCompInfoMarkdown && filePath) {
    const markdownContent = vueCompInfoMarkdown[filePath]
    if (markdownContent) {
      return markdownContent
    }
  }
  return ''
})
onMounted(() => {
  init()
})

async function init() {
  const tmp = await import('virtual:vue-comp-doc')
  vueCompInfoMarkdownMap.value = tmp ? tmp.default : {}
  // console.log('ret.value', tmp.default)
}
</script>

<style scoped></style>
